Determining which index to create

Поиск
Список
Период
Сортировка
От Eric Cholet
Тема Determining which index to create
Дата
Msg-id 697886661.1006345387@[192.168.1.14]
обсуждение исходный текст
Ответы Re: Determining which index to create  (Martijn van Oosterhout <kleptog@svana.org>)
Список pgsql-general
I have the following table :

 Attribute |           Type           | Modifier
-----------+--------------------------+----------
 motid     | integer                  | not null
 objid     | integer                  | not null
 date      | timestamp with time zone | not null

...with 140 million rows. For each distinct value of
motid there are many rows (with different objid/dates).
I would like to optimize the following query:

=> select * from dico_frs where motid=4742 order by date desc limit 10;

Creating an index on 'date' makes the query use that index:

Limit  (cost=0.00..17591.91 rows=10 width=16)
  ->  Index Scan Backward using dico_frs_date on dico_frs
(cost=0.00..20023641.63 rows=11382 width=16)

But it's still quite slow. I'm thinking an index on (motid, date desc)
would be best
but that doesn't seem to be possible. How can I optimize this query?

--
Eric Cholet


В списке pgsql-general по дате отправления:

Предыдущее
От: RoBSD
Дата:
Сообщение: Re: NOTICE: (transaction aborted): queries ignored until END
Следующее
От: "Roman Havrylyak"
Дата:
Сообщение: What size of block should I choose?